package com.tiger.security.sample2;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;

public class Security2TestServlet extends HttpServlet {
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
		response.setContentType("text/html; charset=\"EUC-JP\"");
		PrintWriter out = response.getWriter();
		out.println("<html>");
		out.println("<head>");
		out.println("<title>Security2TestServlet</title>");
		out.println("</head>");
		out.println("<body>");

		try {
			InitialContext ctx = new InitialContext();
			Object obj = ctx.lookup("java:comp/env/ejb/Security2TestBean");
			Security2TestHome securityTestHome = (Security2TestHome) PortableRemoteObject.narrow(obj, Security2TestHome.class);
			Security2Test securityTest = securityTestHome.create();

			out.println("<p>" + securityTest.method1() + "</p>");
		} catch (java.lang.Exception e) {
			out.println("<p>例外" + e.getMessage() + "がスローされました。</p>");
		}

		out.println("</body>");
		out.println("</html>");
		out.close();
	}
}
